<?php

namespace IMT\EventBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use IMT\EventBundle\Entity\File;
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;

/**
 * IMT\EventBundle\Entity\Event
 *
 * @ORM\Table()
 * @ORM\Entity
 */
class Event
{
    /**
     * @var integer $id
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     * @Soap\ComplexType("int", nillable=true)
     */
    private $id;
    
    /**
     * @ORM\Column(type="string", length=200)
     * @Soap\ComplexType("string", nillable=true)
     */
    protected $title;
    
    /**
     * @ORM\Column(type="text")
     * @Soap\ComplexType("string", nillable=true)
     */
    protected $content;
    
    /**
     * @var date $date
     *
     * @ORM\Column(name="date", type="datetime")
     * @Soap\ComplexType("dateTime", nillable=true)
     */
    protected $date;
    
    /**
     * @var date $date
     *
     * @ORM\Column(name="dateFin", type="datetime")
     * @Soap\ComplexType("dateTime", nillable=true)
     */
    protected $dateFin;
    
    /**
     * @var date $creaDate
     *
     * @ORM\Column(name="creaDate", type="date")
     * @Soap\ComplexType("dateTime", nillable=true)
     */
    protected $creaDate;
    
    /**
     * @var date $modifDate
     *
     * @ORM\Column(name="modifDate", type="date", nullable="true")
     * @Soap\ComplexType("dateTime", nillable=true)
     */
    protected $modifDate;
    
    /**
     * @ORM\Column(type="integer")
     * @Soap\ComplexType("int", nillable=true)
     */
    protected $importance;
    
    /**
     * @ORM\Column(type="boolean")
     * @Soap\ComplexType("boolean", nillable=true)
     */
    protected $allDay;
    
    /**
     * @ORM\Column(type="integer")
     */
    protected $owner;
    
    /**
     * @ORM\OneToMany(targetEntity="File", mappedBy="event")
     */
    private $files;
    
    /**
     * @ORM\OneToMany(targetEntity="Comment", mappedBy="event")
     */
    private $comments;
    
    /**
     * @ORM\OneToMany(targetEntity="Alert", mappedBy="event")
     */
    private $alerts;
    
    /**
     * @ORM\OneToMany(targetEntity="IMT\EventBundle\Entity\ParticipantEvent", mappedBy="event", cascade={"persist"})
     */
    private $participants;


    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }
    
    public function __construct()
    {
    	$this->files = new \Doctrine\Common\Collections\ArrayCollection();
    	$this->comments = new \Doctrine\Common\Collections\ArrayCollection();
    	$this->alerts = new \Doctrine\Common\Collections\ArrayCollection();
        $this->date = new \DateTime;
        $this->dateFin = new \DateTime;
    }
    
    public function setDatesToString()
    {
    	foreach(get_object_vars($this) as $attr => $val)
    	{
    		if($val instanceof \DateTime)
    			$this->{$attr} = $this->{$attr}->format('Y-m-d\TH:i:s');
    	}
    }
    
    /**
     * Set title
     *
     * @param string $title
     */
    public function setTitle($title)
    {
        $this->title = $title;
    }

    /**
     * Get title
     *
     * @return string 
     */
    public function getTitle()
    {
        return $this->title;
    }

    /**
     * Set content
     *
     * @param text $content
     */
    public function setContent($content)
    {
        $this->content = $content;
    }

    /**
     * Get content
     *
     * @return text 
     */
    public function getContent()
    {
        return $this->content;
    }

    /**
     * Set date
     *
     * @param date $date
     */
    public function setDate($date)
    {
        $this->date = $date;
    }

    /**
     * Get date
     *
     * @return date 
     */
    public function getDate()
    {
        return $this->date;
    }

    /**
     * Set creaDate
     *
     * @param date $creaDate
     */
    public function setCreaDate($creaDate)
    {
        $this->creaDate = $creaDate;
    }

    /**
     * Get creaDate
     *
     * @return date 
     */
    public function getCreaDate()
    {
        return $this->creaDate;
    }

    /**
     * Set modifDate
     *
     * @param date $modifDate
     */
    public function setModifDate($modifDate)
    {
        $this->modifDate = $modifDate;
    }

    /**
     * Get modifDate
     *
     * @return date 
     */
    public function getModifDate()
    {
        return $this->modifDate;
    }

    /**
     * Set importance
     *
     * @param integer $importance
     */
    public function setImportance($importance)
    {
        $this->importance = $importance;
    }

    /**
     * Get importance
     *
     * @return integer 
     */
    public function getImportance()
    {
        return $this->importance;
    }

    /**
     * Add files
     *
     * @param IMT\EventBundle\Entity\File $files
     */
    public function addFile(\IMT\EventBundle\Entity\File $files)
    {
        $this->files[] = $files;
    }

    /**
     * Get files
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getFiles()
    {
        return $this->files;
    }

    /**
     * Add comments
     *
     * @param IMT\EventBundle\Entity\Comment $comments
     */
    public function addComment(\IMT\EventBundle\Entity\Comment $comments)
    {
        $this->comments[] = $comments;
    }

    /**
     * Get comments
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getComments()
    {
        return $this->comments;
    }

    /**
     * Add alerts
     *
     * @param IMT\EventBundle\Entity\Alert $alerts
     */
    public function addAlert(\IMT\EventBundle\Entity\Alert $alerts)
    {
        $this->alerts[] = $alerts;
    }

    /**
     * Get alerts
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getAlerts()
    {
        return $this->alerts;
    }

    /**
     * Set dateFin
     *
     * @param datetime $dateFin
     */
    public function setDateFin($dateFin)
    {
        $this->dateFin = $dateFin;
    }

    /**
     * Get dateFin
     *
     * @return datetime 
     */
    public function getDateFin()
    {
        return $this->dateFin;
    }

    /**
     * Add participants
     *
     * @param IMT\EventBundle\Entity\ParticipantEvent $participants
     */
    public function addParticipantEvent(\IMT\EventBundle\Entity\ParticipantEvent $participants)
    {
        $this->participants[] = $participants;
    }

    /**
     * Get participants
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getParticipants()
    {
        return $this->participants;
    }

    /**
     * Set allDay
     *
     * @param boolean $allDay
     */
    public function setAllDay($allDay)
    {
        $this->allDay = $allDay;
    }

    /**
     * Get allDay
     *
     * @return boolean 
     */
    public function getAllDay()
    {
        return $this->allDay;
    }

    /**
     * Set owner
     *
     * @param integer $owner
     */
    public function setOwner($owner)
    {
        $this->owner = $owner;
    }

    /**
     * Get owner
     *
     * @return integer 
     */
    public function getOwner()
    {
        return $this->owner;
    }
}